<template>
  <!-- 实名认证 -->
  <view class="root">
    <view class="root-inner">
      <view class="inner-top">
        <view class="wrapper">
          <yy-title title="犬类信息"></yy-title>
          <view class="wrapper-item">
            <view class="label-item">犬类品种:</view>
            <view class="content-item">{{form.breed}}</view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">犬类类型:</view>
            <view class="content-item">{{ form.type || "暂无" }}</view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">数量:</view>
            <view class="content-item">{{ form.quantity || "暂无" }}</view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">是否大型犬:</view>
            <view class="content-item">
              {{ form.largeDogOwnership == 1 ? '是' : '否'  || "暂无" }}
            </view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">检疫状态:</view>
            <view class="content-item">
              {{ form.healthStatus  || "暂无" }}
            </view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">购买时间:</view>
            <view class="content-item">
              {{ form.purchaseDate  || "暂无" }}
            </view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">养殖地点:</view>
            <view class="content-item">
              {{ form.farmLocation  || "暂无" }}
            </view>
          </view>
          <view class="wrapper-item">
            <view class="label-item">犬类图片:</view>
            <view style="color: #2488F5;" class="content-item" v-if="form.imageListUrl && form.imageListUrl.length"
              @click="handlePreviewImg(form.imageListUrl)">
              查看
            </view>
            <view class="content-item" v-else>
              暂无
            </view>
          </view>
        </view>
        <view class="wrapper">
          <yy-title title="物品所有人"></yy-title>
          <view class="wrapper-item">
            <view class="label-item">所属类型:</view>
            <view class="content-item">{{ form.typeCode == 0 ? '个人所有' : '单位所有' || "暂无" }}</view>
          </view>
          <view class="" v-if="form.typeCode == 0">
            <view class="wrapper-item">
              <view class="label-item">身份证号:</view>
              <view class="content-item">{{ encryptIDCard(form.personIdCard) || "暂无" }}</view>
            </view>
            <view class="wrapper-item">
              <view class="label-item">姓 名:</view>
              <view class="content-item">{{ form.personName || "暂无" }}</view>
            </view>
            <view class="wrapper-item">
              <view class="label-item">联系电话:</view>
              <view class="content-item">{{ form.personPhone || "暂无" }}</view>
            </view>
          </view>
          <view v-else>
            <view class="wrapper-item">
              <view class="label-item">单位名称:</view>
              <view class="content-item">{{ form.companyMessageName || "暂无" }}</view>
            </view>
            <view class="wrapper-item">
              <view class="label-item">联系方式:</view>
              <view class="content-item">{{ form.companyMessagePhone || "暂无" }}</view>
            </view>
          </view>
        </view>

      </view>
    </view>
  </view>
  </view>
</template>

<script>
  import {
    electricvehiclesDeleteInfo,
    electricvehiclesDetails,
    getDogIdInfo,
    getUnlockRecordById
  } from "@/api/api.js";
  import {
    Toast,
    getOptionsParams,
    isLoading,
    navBack,
    navTo,
    previewImage,
    pvwImage,
    encryptIDCard,
    logoutButton
  } from "@/utils/util.js";
  import moment from "@/utils/moment";

  export default {
    data() {
      return {
        baseImgUrl: this.$baseImgUrl,
        baseURL: this.$baseURL,
        imgPrefix: uni.getStorageSync("imgPrefix"),
        form: {},
        errorType: ["none"],
        routerParams: {},
        logoutButton
      };
    },
    onLoad(options) {
      this.routerParams = getOptionsParams(options, 'params')
    },
    onShow() {
      this.getDetail();
    },
    methods: {
      encryptIDCard,
      pvwImage,
      moment,
      getDetail() {
        getDogIdInfo({
          id: this.routerParams.id
        }).then((res) => {
          if (res.code == 200) {
            this.form = res.result;
          }
        });
      },
      handleRemoveRegister() {
        uni.showModal({
          title: "提示",
          content: "请确认是否解除备案？",
          confirmColor: "#2488F5",
          success: async (res) => {
            if (res.confirm) {
              const params = {
                id: this.routerParams.id
              }
              isLoading()
              electricvehiclesDeleteInfo(params)
                .then((res) => {
                  if (res.code === 200) {
                    Toast('解除备案成功！')
                    setTimeout(() => {
                      uni.$emit('register-load')
                      navBack()
                    }, 250)
                  } else {
                    Toast(res.message)
                  }
                })
                .finally(() => {
                  isLoading(false)
                })
            }
          },
        });
      },
      handleReport() {
        navTo({
          url: '/itemRegistration/lossInformationCar',
          params: {
            id: this.form.id
          }
        })
      },
      handlePreviewImg(urls) {
        previewImage.call(this, urls)
      }
    },
  };
</script>

<style>
  page {
    background-color: #f3f3f3 !important;
    height: 100%;
  }
</style>
<style lang="scss" scoped>
  .root {
    flex: 1;
    background-color: #f3f3f3;

    .root-inner {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;

      .inner-top {
        flex: 1;
        overflow: auto;
        padding-bottom: 10rpx;
      }
    }



    /deep/.title-s-n {
      padding-top: 20rpx !important;
      padding-bottom: 20rpx !important;
    }

    .wrapper {
      width: 718rpx;
      background: #FFFFFF;
      border-radius: 16rpx 16rpx 16rpx 16rpx;
      margin: 0 auto;
      padding: 0 27rpx;
      margin-top: 10rpx;

      .wrapper-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1rpx solid #F3F0F0;
        padding-top: 48rpx;
        padding-bottom: 21rpx;

        &:last-child {
          border: 0;
        }

        .label-item {
          font-size: 28rpx;
          color: #7F7E83;
          flex-shrink: 0;
          margin-right: 30rpx;
        }

        .content-item {
          font-weight: bold;
          font-size: 28rpx;
          color: #333333;
        }
      }

      .photo-class {
        width: 90rpx;
        height: 56rpx;
      }
    }
  }
</style>